﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using HYCodeBase.Math;

namespace HYRevitCode.GeometryUtility
{
	public static class GeometryUtilityMethod
	{
		public static List<Solid> GetAllSolid(GeometryElement inputValue, Transform useTransform = null)
		{
			List<Solid> list = new List<Solid>();
			if (!(null == inputValue))
			{
				GeometryElement geometryElement = inputValue;
				if (useTransform != null)
				{
					geometryElement = geometryElement.GetTransformed(useTransform);
				}
				foreach (GeometryObject geometryObject in geometryElement)
				{
					if (!(null == geometryObject))
					{
						if (null != geometryObject as Solid && MathUtility.GreaterThan((geometryObject as Solid).Volume, 0.0))
						{
							list.Add(geometryObject as Solid);
						}
						if (geometryObject is GeometryInstance)
						{
							list.AddRange(GeometryUtilityMethod.GetAllSolid((geometryObject as GeometryInstance).GetSymbolGeometry((geometryObject as GeometryInstance).Transform), null));
						}
					}
				}
			}
			return list;
		}
	}
}
